package org.jeecg.modules.demo.officialaccountuser.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.aspect.annotation.AutoLog;
import org.jeecg.common.system.base.controller.JeecgController;
import org.jeecg.modules.demo.officialaccounttoken.entity.OfficialAccountToken;
import org.jeecg.modules.demo.officialaccounttoken.service.IOfficialAccountTokenService;
import org.jeecg.modules.demo.officialaccountuser.entity.OfficialAccountUser;
import org.jeecg.modules.demo.officialaccountuser.service.IOfficialAccountUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * @Description: 公众号关注者
 * @Author: kevin
 * @Date: 2022-05-09
 * @Version: V1.0
 */
@Api(tags = "公众号关注者")
@RestController
@RequestMapping("/officialaccountuser/officialAccountUser")
@Slf4j
public class OfficialAccountUserController extends JeecgController<OfficialAccountUser, IOfficialAccountUserService> {
    @Autowired
    private IOfficialAccountUserService officialAccountUserService;
    @Autowired
    private IOfficialAccountTokenService officialAccountTokenService;

    /**
     * 查询关注者列表
     *
     * @return
     */
    @AutoLog(value = "查询关注者列表")
    @ApiOperation(value = "查询关注者列表", notes = "查询关注者列表")
    @GetMapping(value = "/getOfficialAccountUser")
    public Result<?> getOfficialAccountUser(HttpServletRequest req) {
        OfficialAccountToken officialAccountToken = officialAccountTokenService.getToken("wx42ecd92353c89e9f", "955609cb9cb5d3ee036caaed2f883277");
        if (officialAccountToken != null) {
            List<String> listOpenId = officialAccountUserService.getUserOpenId(officialAccountToken.getToken(), "");
            if (listOpenId != null) {
                if (listOpenId.size() > 0) {
                    List<OfficialAccountUser> listOfficialAccountUser = officialAccountUserService.getUserInfo(listOpenId);
                }
            }
        }
        return Result.OK();
    }
}
